import moment from 'moment'

/**
 * Format a timestamp to a locale string
 * @param timestamp
 */
export function formatToLocaleString(timestamp: number): string {
  if (!timestamp || timestamp === 0) {
    return ''
  }
  return new Date(timestamp).toLocaleString()
}

export function getLastDays(days: number) {
  const dates = []
  for (let i = 0; i < days; i++) {
    const date = moment().subtract(i, 'days')
    dates.unshift(date.format('YYYY-MM-DD')) // 使用 moment.js 格式化为 YYYY-MM-DD
  }
  return dates
}
